<?php namespace Home\Controller; 

use Hdphp\Controller\Controller;

//前台控制器
class IndexController extends Controller{
	
    //首页
    public function index(){
    	//显示最新的5篇文章并以降序的顺序排列
    	$arcData = Db::table('article')
				   ->join('category','cid','=','category_cid')
				   ->orderBy('sendtime','DESC')
				   ->limit(5)
				   ->get();
		$tagModel = new \Common\Model\Tag;
		//调用模型获取标签的方法给原有的文章数据组合上标签
		$arcData = $tagModel->getTag($arcData);
		View::with('arcData',$arcData);
		
		//分页处理*************
		//统计总数SELECT count(*) FROM...
		$total = Db::table('article')->join('category','category_cid','=','cid')->where("is_recycle=0")->count();
		//执行分页，每一页有两篇文章
		$page = Page::row(3)->make($total);
		View::with('page',$page);
			
		View::make();		
    }
	
	//显示验证码
	public function code(){
		//获取验证码长度
		$num = Config::get('self.codelen');
		//显示验证码
		Code::num($num)->make();
	}
}





